//
//  FCTableView.swift
//  FinancialConsulting
//
//  Created by Max on 2017/10/31.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

class FCTableView: UITableView {

    private let label = UILabel()
    var autoShowNoResultsLabel = false
    //  var noResultText = "Search_No_Results".localString
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        self.superview?.endEditing(true)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = UIColor.white
        label.font = UIFont.boldSystemFont(ofSize: 14)
        label.textColor = UIColor.gray
        label.isHidden = true
        self.addSubview(label)
    }
    
    override func reloadData() {
        super.reloadData()
        if !autoShowNoResultsLabel { return }
        if numberOfSections == 0 || numberOfRows(inSection: 0) == 0 {
            label.sizeToFit()
            label.isHidden = false
        } else {
            label.isHidden = true
        }
    }
    

}
